﻿/*
Created By:     lixueming
Created When:   2012-4-1
Created Whys:    MyAccount 个人设置
*/
function AccountReminderCallBack(flag) {
    if (flag == 1) {
        alert("ReminderAll success!");
    } else {
        alert("ClearReminder success!");
        //回调处理ClearReminder button
    }
}
function AccountReminder(flag) {
    var cmdpara = flag == 1 ? "ReminderAll" : "ClearReminder";
   // alert(cmdpara);
    $.ajax({
        type: "GET",
        url: "/GateService/MyAccountAjax.aspx",
        dataType: "json",
        data: "cmd=" + cmdpara + "&langID=" + g_langID + "&random=" + new Date().toLocaleString(),
        beforeSend: function (XMLHttpRequest) {
        },
        success: function (data, textStatus) {
            var notmapevent = g_langID == 1033 ? "Please note the Remind activity" : "用户没有设置提醒的活动";
            var haseventset = g_langID == 1033 ? "has set up" : "用户已经设置了提醒";
            var canceleventmap = g_langID == 1033 ? "Note the concept has been cancelled" : "用户已经清理了提醒";
            if (data != null && data.Result) {
                //AccountReminderCallBack(flag);
                GetLastEvents();
            } else {
                if (flag == 1) {
                    var message = parseInt(data.Message);
                    if (message == 1) {
                        //当前用户没有收藏活动
                        alert(notmapevent);
                    } else {
                        //已经设置过
                        alert(haseventset);
                    }
                } else {
                    var message1 = parseInt(data.Message);
                    if (message1 == 1) {
                        //当前用户没有收藏活动
                        alert(notmapevent);
                    } else {
                        //已经清理过
                        alert(canceleventmap);
                    }

                }
            }


        },
        complete: function (XMLHttpRequest, textStatus) {
            //隐藏正在查询图片
        },
        error: function () {
            //错误处理
            alert("error");
        }
    });
}

//取个人提醒设置
function GetRemindarSet() {
    $.ajax({
        type: "GET",
        url: "/GateService/MyAccountAjax.aspx",
        dataType: "json",
        data: "cmd=GetRemindarSet&langID=" + g_langID + "&random=" + new Date().toLocaleString(),
        beforeSend: function (XMLHttpRequest) {
        },
        success: function (data, textStatus) {
            if (data != null) {
                var COL_REM_BY_EMAIL = IsNull(data.COL_REM_BY_EMAIL);
                var COL_REM_EMAIL = IsNull(data.COL_REM_EMAIL);
                var COL_REM_BY_MOBILE = IsNull(data.COL_REM_BY_MOBILE);
                var COL_REM_MOBILE = IsNull(data.COL_REM_MOBILE);
                if (COL_REM_BY_EMAIL == "True")
                    $("#chk_emailset").attr("checked", true);
                if (COL_REM_BY_MOBILE == "True")
                    $("#chk_mobileset").attr("checked", true);
                $("#txt_emailset").attr("value", COL_REM_EMAIL);
                $("#txt_mobileset").attr("value", COL_REM_MOBILE);

            }
        },
        complete: function (XMLHttpRequest, textStatus) {

        },
        error: function () {
            //错误处理
        }
    });
}

$(function () {
    $("#formset").submit(function (e) {
        e.preventDefault();
        var dataString = $("#formset").serialize();
        //alert(dataString);
        $.ajax({
            type: "POST",
            url: "/GateService/MyAccountAjax.aspx",
            data: dataString + "&cmd = SaveRemSet&langID=" + g_langID + "&random=" + new Date().toLocaleString(),
            dataType: "json",
            success: function (data) {
                alert(data.Message);

            }

        });

    });
});

function GetMyAccount() {
    $.ajax({
        type: "GET",
        url: "/GateService/MyAccountAjax.aspx",
        dataType: "json",
        data: "cmd=MyAccount&langID=" + g_langID + "&random=" + new Date().toLocaleString(),
        beforeSend: function (XMLHttpRequest) {
        },
        success: function (data, textStatus) {
            $('#Dynamic_MyAccoutContent').html("");
            var html = $('#Dynamic_MyAccoutContent');
            var str = "";
            //alert(eval(data.Table.row[0].City));
            //alert(data);
            $.each(data.Table, function (index, row) {
                var username = IsNull(row.MEMBER_NAME);
                //alert(username);
                var MEMBER_HERD_IMG = IsNull(row.MEMBER_HERD_IMG);
                var City = IsNull(row.City);
                var Provice = IsNull(row.Provice);
                var cnProvice = IsNull(row.cnProvice);
                var enProvice = IsNull(row.enProvice);
                var cnCity = IsNull(row.cnCity);
                var enCity = IsNull(row.enCity);
                var favoritecount = IsNull(row.favoritecount);
                var Commentscount = IsNull(row.Commentscount);
                var BIRTHDAY = IsNull(row.BIRTHDAY);
                var MOBLIE = IsNull(row.MOBLIE);
                var COL_EVENTS_TIME_SHOW = IsNull(row.COL_EVENTS_TIME_SHOW);
                var Interests = IsNull(row.Interests);
                var path = g_langID == 2052 ? "/cn/" : "/en/";
                var showcity;
                if (g_langID == 2052) {
                    showcity = cnCity == null ? City : cnCity;
                } else {
                    showcity = enCity == null ? City : enCity;
                }
                var showimg = MEMBER_HERD_IMG != "" ? Environment.FilePath.UploadFrontImagePath + "/" + MEMBER_HERD_IMG : globals.header_def;
                //alert(showimg);

                str += " <div class=\"head\"><img onerror='this.src=\"" + globals.header_def + "\"' src=" + showimg + " width=\"174\" height=\"174\" alt=\"\"></div>";
                str += "                 <dl>";
                str += "                 	<dt>" + username + " </dt>";
                str += "                    <dd><a href=" + path + "myprofile.html ><span>"+MyProfileConst.edit+"</span></a></dd>";
                str += "                 </dl>";
                str += "                 <ul>";
                str += "                 	<li><span>" + MyProfileConst.at + ":</span> " + showcity + "</li>";
                str += "                 	<li><span>" + MyProfileConst.Mob + ":</span> " + MOBLIE + "</li>";
                str += "                    <li><span>" + MyProfileConst.Birthday + ":</span> " + BIRTHDAY + "</li>";
                str += "                     <li><span>" + MyProfileConst.Interests + ":</span> " + Interests + "</li>";
                str += "                    <li><span>" + MyProfileConst.Favoriteevents + ":</span> " + favoritecount + "</li>";
                str += "                     <li><span>" + MyProfileConst.Comments + ":</span> " + Commentscount + "</li>";
                str += "                 </ul>";
                str += "<div class=\"clearfix\"><span>Clear Line</span></div>";
            });

            html.append(str);
        },
        complete: function (XMLHttpRequest, textStatus) {

        },
        error: function () {
            alert("出错了");
            //错误处理
        }
    });
}
